package collage.aminpage;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.util.Calendar;
import java.util.GregorianCalendar;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class Calendar_body extends JPanel{
	
	private static Calendar cal;
	
	
	public Calendar_body() {


		setBorder(new EmptyBorder(5, 5, 5, 5));
		setLayout(new BorderLayout(0, 0));
		
	
		makeSelectCal();
		makePoint();
				
	}
	

	private void makeSelectCal(){
		
		JPanel total = new JPanel();
		
		total.setLayout( new BoxLayout( total, BoxLayout.Y_AXIS ));
		
		JPanel topPanel = new JPanel();
	
		
		cal = new GregorianCalendar();
		int year = cal.get( Calendar.YEAR );
		int month = cal.get( Calendar.MONTH ) + 1;
		int date = cal.get( Calendar.DATE );
		
		
		
		JButton bMonth = new JButton("-month");
		topPanel.add(bMonth);
		

		JLabel thisYear = new JLabel(  year + "년");
		topPanel.add( thisYear );
		
		JLabel thisMonth = new JLabel(  month + "월");
		topPanel.add(thisMonth);
		
		JButton gMonth = new JButton("+month");
		topPanel.add(  gMonth );
		
		
		JPanel dayPanel = new JPanel();
		dayPanel.setLayout(new GridLayout(0, 7, 0, 0)); // gridLayout 5* 7 총 35개의 패널생성
		
		JPanel[] dayPNem = new JPanel[7];
		JLabel[] dayNem = new JLabel[7];
		
		dayNem[0] = new JLabel( "Sunday" );
		dayNem[1] = new JLabel( "Monday" );
		dayNem[2] = new JLabel( "Thusday" );
		dayNem[3] = new JLabel( "Wensday" );
		dayNem[4] = new JLabel( "Thurthday" );
		dayNem[5] = new JLabel( "Friday" );
		dayNem[6] = new JLabel( "Saterday" );
		
		// 일자등록
		for ( int i = 0 ; i <=6 ; i++) {
			dayPNem[i]  = new JPanel();
			dayPNem[i].add(dayNem[i]);
			dayPanel.add(dayPNem[i]);
						
		}
		
		total.add( topPanel );
		total.add( dayPanel );
		
		add(total, BorderLayout.NORTH);
		
		
	}
	
	private void makeDay(){
	
		
		}
	
	//http://arabiannight.tistory.com/
		
 private void makePoint(){
		JPanel body = new JPanel();
		add(body, BorderLayout.CENTER); 
		body.setLayout(new GridLayout(5, 7, 0, 0)); // gridLayout 5* 7 총 35개의 패널생성
		
		// 각 패널및 버튼 생성
		JPanel[] point =  new JPanel[36];
		JButton[] btn = new JButton[36];
				
		for ( int i = 1 ; i <= 35; i++){
			point[i] = new JPanel();
			btn[i] = new JButton( i + "btn");
			point[i].add( btn[i] );
			
			body.add( point[i] );
						
		} // 버튼
		
		// 각 버튼날짜 생성
		cal = new GregorianCalendar();
		int year = cal.get( Calendar.YEAR );
		int month = cal.get( Calendar.MONTH );
		int date = cal.get( Calendar.DATE );
	/*	
		Calendar firstdate = cal.getInstance();
		firstdate.set( 2013, 11, 01);
		
		
		
		for ( int i = cal.get( firstdate ) ;  )
		
		*/
		
		
		
		
		
	}
	
	
	private static void getCalendar(){
	
	}
		
}// class
